package com.xlh.openai.controller;

import com.xlh.openai.common.Result;
import com.xlh.openai.service.impl.OpenAiChatServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;

import java.util.ArrayList;

@Api(tags = "OpenAiChatApi")
@RestController
@RequestMapping("foreign")
public class OpenAiChatApi {
 
    @Autowired
    private OpenAiChatServiceImpl openAiChatBiz;

    @ApiOperation(value = "提问的问题",notes = "  使用什么取样温度，0到2之间。越高越奔放。越低越保守。")
    @RequestMapping(path = "/chat/question",method = RequestMethod.GET)
    public Result<String> openAiChat(@RequestParam("prompt")String prompt,
                                     @RequestParam("temperature") Double temperature ){
        return Result.success(openAiChatBiz.chat(prompt, temperature));
    }

}